package com.thb.pay.manage.web.merchant;


import com.thb.pay.api.merchant.MchNotifyServiceApi;
import com.thb.pay.api.merchant.vo.req.MchNotifyPageReq;
import com.thb.pay.api.merchant.vo.resp.MchNotifyVo;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.core.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商户-通知表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@RestController
@RequestMapping("/api/sys/mchNotify")
public class MchNotifyController {

    @Autowired
    private MchNotifyServiceApi mchNotifyServiceApi;

    /**
     * 商户通知记录列表
     * @return
     */
    @PostMapping("/list")
    public R list(@RequestBody MchNotifyPageReq pageReq) {
        PageResult<MchNotifyVo> pageResult = mchNotifyServiceApi.findPage(pageReq);
        return R.okData(pageResult);
    }

    /**
     * 查询单条商户通知记录
     * @return
     */
    @RequestMapping("/get")
    public R get(@RequestParam("orderId") String orderId) {
        MchNotifyVo resultData = mchNotifyServiceApi.findByOrderId(orderId);
        return R.okData(resultData);
    }

    /**
     * 重发通知(待实现)
     * @return
     */
    @RequestMapping("/resend")
    public R resend(@RequestParam("orderIds") String orderIds) {
        return R.ok(mchNotifyServiceApi.resend(orderIds));
    }
}
